<!DOCTYPE html>
<!--
This is a starter template page. Use this page to start your new project from
scratch. This page gets rid of all links and provides the needed markup only.
-->
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org"
	xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:replace="top::html" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>AdminLTE 2 | Starter</title>
<!-- Tell the browser to be responsive to screen width -->
<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
	name="viewport">

<body class="fixed hold-transition skin-blue">
	<div class="wrapper">

		<!-- Main Header -->
		<div th:replace="tophtml::html"></div>
		<!-- Left side column. contains the logo and sidebar -->
		<div th:replace="left::html"></div>

		<!-- Content Wrapper. Contains page content -->
		<div class="content-wrapper">
			<!-- Content Header (Page header) -->
			<section class="content-header">
				<h1>
					Page Header <small>Optional description</small>
				</h1>
				<ol class="breadcrumb">
					<li><a href="#"> <i class="fa fa-dashboard"></i> Level
					</a></li>
					<li class="active">Here</li>
				</ol>
			</section>

			<!-- Main content -->
			<section class="content container-fluid">
				<p style="color: red;" th:text="${searchEmpty}"></p>
				<form th:action="@{/customer/showProjectConditionQuery}"
					method="get" id="from1">
					<input type="hidden" name="pageNo" id="pageNo" /> <input
						type="hidden" name="customerId" id="customerId"
						th:value="${customerId}" />
					<div class="form-group">
						<input style="width: 500px; display: inline" type="text"
							class="form-control" placeholder="id或名称" name="searchKeyword"
							th:value="${searchKeyword}">
					</div>
					<div class="form-group">
						<label>项目类型</label> <span
							th:each="ptd : ${projectTypeDictiontryList}"> <input
							type="checkbox" name="projectType" th:value="${ptd.names}"
							th:text="${ptd.worth}"
							th:checked="${projectTypedArr != null ? #arrays.contains(projectTypedArr, ptd.names) : false}">
						</span>
					</div>
					<div class="form-group">
						<label>所属领域</label> <span
							th:each="rfd : ${researchFieldDictiontryList}"> <input
							type="checkbox" name="researchField" th:value="${rfd.names}"
							th:text="${rfd.worth}"
							th:checked="${researchFieldArr != null ? #arrays.contains(researchFieldArr, rfd.names) : false}">
						</span>
					</div>
					<div>
						<span class="from-group"> <label>国内国外</label> <input
							type="radio" name="domesticOrForeign" id="optionsRadios1"
							value="0"
							th:checked="${project != null ? project.domesticOrForeign == 0 : false}">
							国内 <input type="radio" name="domesticOrForeign"
							id="optionsRadios2" value="1"
							th:checked="${project != null ? project.domesticOrForeign == 1 : false}">
							国外
						</span> <span class="form-group form-area"> <select
							class="form-area" id="provinceId">
								<option value="-1">--选择省--</option>
								<option th:each="list:${provinceDictiontryList}"
									th:value="${list.names}" th:text="${list.worth}"
									th:selected="${list.names eq province}"></option>
						</select>
						</span> <span class="form-group form-area"> <select
							class="form-area" id="cityId">
								<option value="-1">--选择市--</option>
								<option th:each="list:${cityDictiontryList}"
									th:value="${list.names}" th:text="${list.worth}"
									th:selected="${list.names eq city}"></option>
						</select>
						</span> <span class="form-group form-area"> <select
							class="form-area" id="areaId">
								<option value="-1">--选择区--</option>
								<option th:each="list:${areaDictiontryList}"
									th:value="${list.names}" th:text="${list.worth}"
									th:selected="${list.names eq district}"></option>
						</select>
						</span> <span class="form-group form-country"> <select
							class="form-area">
								<option value="-1">--选择国家--</option>
								<option th:each="list:${countryDictiontryList}"
									th:value="${list.pid}" th:text="${list.worth}"
									th:selected="${list.pid eq country}"></option>
						</select>
						</span>
						<button type="submit" class="btn btn-primary">检索</button>
					</div>
				</form>

				<div class="box-header with-border">
					<h3 class="box-title">
						<button class="btn btn-primary" id="dosubmit">匹配</button>
						<button class="btn btn-primary" id="goback">返回</button>
					</h3>
				</div>
				<div class="box-body">
					<table class="table table-bordered">
						<tbody>
							<tr>
								<th><input id="all" type="checkbox" /></th>
								<th>项目id</th>
								<th>项目名称</th>
								<th>项目类型</th>
								<th>项目状态</th>
								<th>联系人</th>
							</tr>
							<tr th:each="project, stat : ${pageInfo.list}">
								<td><input type="checkbox" name="check"
									th:value="${project.pid}" /></td>
								<td th:text="'R' + ${project.projectNumber}">560</td>
								<td th:text="${project.projectName}">飞行汽车</td>
								<td th:text="${project.projectType}">类型</td>
								<td th:text="${project.projectStatusWorth}">状态</td>
								<td><a
									th:href="@{'/project/showUpdateContact?projectContactId='+${project.per == null ? '' : project.per.pid}}"
									th:text="${project.per == null ? '' : project.per.name}">联系人</a>
								</td>
							</tr>
						</tbody>
					</table>
					<p style="color: red;" th:text="${notHolderUpdate}"></p>
					<p style="color: red;" th:text="${projectContactExists}"></p>
					<p style="color: red;" th:text="${projectContactNotExists}"></p>
					<div th:replace="page::html"></div>
				</div>
			</section>
			<!-- /.content -->
		</div>
		<!-- /.content-wrapper -->

		<!-- Main Footer -->
		<div th:replace="footer::html"></div>
		<div class="control-sidebar-bg"></div>
	</div>
	<!-- ./wrapper -->

	<!-- REQUIRED JS SCRIPTS -->

	<!-- jQuery 3 -->
	<script src="/bower_components/jquery/dist/jquery.min.js"></script>
	<!-- Bootstrap 3.3.7 -->
	<script src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
	<!-- AdminLTE App -->
	<script src="/dist/js/adminlte.min.js"></script>
	<script src="/js/formValid.js"></script>

	<!-- Optionally, you can add Slimscroll and FastClick plugins.
     Both of these plugins are recommended to enhance the
     user experience. -->
</body>



<script type="text/javascript">
	$("#all").click(function() {

		$("input[name='check']").prop("checked", this.checked);

	});

	$('#dosubmit')
			.click(
					function() {
						var checkID = [];//定义一个空数组
						//获取客户id
						var customerId = $("#customerId").val();

						$("input[name='check']:checked").each(function(i) {
							//把所有被选中的复选框的值存入数组
							checkID[i] = $(this).val();
						});

						var basePath = '[[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]]';

						var checkStr = checkID.join(",");
						//用Ajax传递参数
						$.ajax({
							url : basePath + '/customer/saveCompareProject',
							data : {
								'customerId' : customerId,
								'checkStr' : checkStr
							},
							type : 'get',
							async : true,
							success : function(data) {
								if (data == "success") {
									alert("匹配成功");
								}
							}
						});
					})

	$('#goback').click(function() {
		window.history.go(-1);
	})
</script>
</html>